﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;

namespace AlphaSolutionsGP.Demo_classes
{
    class StudentDemo
    {
        private Student s;
        private Student s2;
        private string passorfail;
        private int _pass;
        private int _fail;

       
        
        public StudentDemo()
        {
            _pass=0;
            _fail=0;
            #region checks
            if (testStudentNoArgConstructor() == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            if (testStudentArgConstructor() == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            if (testStudentGettersAndSetters() == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            if (testCreateMethod() == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            
            if (testAmmendMethod() == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            if (testDeleteMethod() == false)
            {
                _fail++;
            }
            else
            {
                _pass++;
            }
            #endregion
            


        }
        bool testStudentNoArgConstructor()
        {
            bool success = false;
            try
            {
                s = new Student();
                success = true;
            }
            catch(Exception e)
            {
                success = false;
            }
            return success;
        }
        bool testStudentArgConstructor()
        {
            bool success = false;
            try
            {
                s2 = new Student(20010427, "2013-04-16",1,"2020-04-16", "test", "nowhere", "ENVI01","test", "hometown", "active", "Joe", "Mathew","Bloggs", "01385940322", "joe.blogs@aol.com", "joe.bloggs@woodlands.com", "co6 8fg","123 fake street","London", "01928374859", "1992-10-01");
                success = true;
            }
            catch (Exception e)
            {
                success = false;
            }
            return success;
        }
        


        bool testStudentGettersAndSetters()
        {
            bool success = false;
            try
            {
                string name = s2.FirstName;
                string surname = s2.Surname;
                string status = s2.Status;
                string imageLocation = s2.ImageLocation;
                string password = s2.Password;
                success = true;

            }
            catch (Exception e)
            {
                 success = false;
            }


            return success;
        }
        bool testCreateMethod()
        {
            bool success = false;
            try
            {
               // MySqlConnection connection = new MySqlConnection("server=194.81.104.22;" + "User Id=alpha;" + "database=alpha_db;" + "password=bravo;");    

                s2.createStudent();
                success = true;

            }
            catch (Exception e)
            {
                success = false;
            }


            return success;
        }
        bool testAmmendMethod()
        {
            bool success = false;
            try
            {
                s2.FirstName = "ammended";
                s2.amendStudent();
                success = true;

            }
            catch (Exception e)
            {
                success = false;
            }


            return success;
        }
        bool testDeleteMethod()
        {
            bool success = false;
            try
            {
                s2.deleteStudent();
                success = true;

            }
            catch (Exception e)
            {
                success = false;
            }


            return success;
        }
        public int Fail
        {
            get { return _fail; }
            set { _fail = value; }
        }

        public int Pass
        {
            get { return _pass; }
            set { _pass = value; }
        }

        public string PassOrFail
        {
            get { return passorfail; }
            set { passorfail = value; }
        }
    }
}
